
val_name = '/home/sean/data/ILSVRC/ImageSets/VID/val.txt'
val_reduce_video_name = '/home/sean/data/ILSVRC/ImageSets/VID/val_video_small.txt'
pre_video_name = None
video_num = 0
video_matain = False
video_matain_num = 0

with open(val_reduce_video_name, 'w') as wf:
    for line in open(val_name, 'r'):
        line_split = line.split('/')
        video_name = line_split[0]
        if video_name != pre_video_name:
            video_num += 1
            pre_video_name = video_name
            if video_num % 5 ==1:
                video_matain = True
                video_matain_num += 1
            else:
                video_matain = False
        if video_matain:
            wf.write(line)

print(video_num, video_matain_num)